package com.ruoyi.edge.application.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.application.domain.ServiceManagement;
import com.ruoyi.edge.application.service.ServiceManagementService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 服务管理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/service")
public class ServiceManagementController extends BaseController {

    private final ServiceManagementService serviceManagementService;

    /**
     * 获取列表
     */
    @SaCheckPermission("edge:service:listPage")
    @GetMapping("/listPage")
    public TableDataInfo<ServiceManagement> listPage(ServiceManagement serviceManagement, PageQuery pageQuery) {
        return serviceManagementService.listPage(serviceManagement, pageQuery);
    }

    /**
     * 获取详情
     */
    @SaCheckPermission("edge:service:get")
    @GetMapping("/get")
    public R<ServiceManagement> get(String id) {
        return serviceManagementService.get(id);
    }

    /**
     * 新增
     */
    @SaCheckPermission("edge:service:add")
    @PostMapping("add")
    public R<String> add(@RequestBody ServiceManagement serviceManagement) {
        return serviceManagementService.add(serviceManagement);
    }

    /**
     * 编辑
     */
    @SaCheckPermission("edge:service:edit")
    @PutMapping("edit")
    public R<String> edit(@RequestBody ServiceManagement serviceManagement) {
        return serviceManagementService.edit(serviceManagement);
    }

    /**
     * 删除
     */
    @SaCheckPermission("edge:service:remove")
    @DeleteMapping("remove")
    public R<String> remove(String id) {
        return serviceManagementService.remove(id);
    }
}
